/*
 * 2011 Runedev development team
 * http://lazygamerz.org
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser Gereral Public Licence as published by the Free
 * Software Foundation; either version 3 of the Licence, or (at your opinion) any
 * later version.
 *
 * This library is distributed in the hope that it will be usefull, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of merchantability or fitness for a
 * particular purpose. See the GNU Lesser General Public Licence for more details.
 *
 * You should have received a copy of the GNU Lesser General Public Licence along
 * with this library; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, Ma 02111-1307 USA.
 *
 * http://www.gnu.org/licenses/lgpl.html (English)
 * http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Espa�ol)
 *
 */
package org.rsbot.script.randoms;

import org.rsbot.script.Random;
import org.rsbot.script.ScriptManifest;

/**
 * @author Secret Spy
 * @version 1.1 - 02/10/11
 */
@ScriptManifest(name = "LeaveSafeArea", authors = "Secret Spy", version = 1.1)
public class LeaveSafeArea extends Random {

	@Override
	public boolean activateCondition() {
		return (iface.getChild(212, 2).containsText("things can get more") &&
				(iface.getChild(212, 2).getAbsoluteY() > 380) &&
				(iface.getChild(212, 2).getAbsoluteY() < 410)) ||
				(iface.getChild(236, 1).containsText("the starting area") &&
						(iface.getChild(236, 1).getAbsoluteY() > 390) &&
						(iface.getChild(236, 1).getAbsoluteY() < 415));
	}

	@Override
	public int loop() {
		if (iface.canContinue()) {
			iface.clickContinue();
			sleep(random(1000, 1200));
		}
		iface.clickChild(236, 1);
		return -1;
	}

}
